<?php //strip
/**
 * Class that implements newsletter model.
 * 
 * @package odPhotogalleryWpPlugin
 * @subpackage odPhotogalleryWpPlugin_Models
 * @author Ondrej Donek <ondrejd@gmail.com>
 * 
 * @todo We need to upgrade database table scheme!!!
 * 
 * Original scheme:
 * <code>
 * CREATE TABLE IF NOT EXISTS `wp_fotogalerie_files` (
 *   `ID` int(11) NOT NULL auto_increment,
 *   `gallery_ID` int(11) NOT NULL default '0',
 *   `title` varchar(255) collate utf8_general_ci NOT NULL,
 *   `description` tinytext collate utf8_general_ci NOT NULL,
 *   `file` varchar(255) NOT NULL,
 *   `order` bigint(20) NOT NULL default '0',
 *   `display` tinyint(1) NOT NULL default '1',
 *   PRIMARY KEY  (`ID`)
 * ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ;
 * </code>
 */
class odPhotogalleryWpPlugin_Models_Photogallery_Files 
    extends odWpPlugin_Model_Simple
{
  /**
   * Construct newsletter model.
   * 
   * @global wpdb $wpdb
   * @return void
   */
  public function __construct()
  {
    if(defined('IS_UNITTESTING') && IS_UNITTESTING) {
      $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
    } else {
      global $wpdb;
    }
    
    $this->mTableName = $wpdb->prefix . 'newsletter';
    $this->mPrimary = 'ID';
    $this->mCheckColumn = 'title';
    $this->mColumns = array(
        'ID' => array('type' => 'bigint', 'length' => 20, 'primary' => true),
        'subject' => array('type' => 'varchar', 'length' => 255, 'notnull' => true, 'default' => ''),
        'text_body' => array('type' => 'text', 'notnull' => true),
        'html_body' => array('type' => 'text', 'notnull' => true),
        'recipients' => array('type' => 'text', 'notnull' => true),
        'created' => array('type' => 'timestamp', 'notnull' => true, 'default' => 'CURRENT_TIMESTAMP'),
        'sent' => array('type' => 'tinyint', 'length' => 1, 'notnull' => true, 'default' => 0),
        'sent_when' => array('type' => 'timestamp', 'notnull' => true)
    );
  }
} // End of odPhotogalleryWpPlugin_Models_Photogallery_Files
